﻿using Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project_V1//新建变量窗体内的值如何传递
{
    public partial class Frm_NewVar_Mod : Form
    {
        public Frm_NewVar_Mod()
        {
            InitializeComponent();
            this.Load += Frm_NewVar_Mod_Load;//添加load事件,初始化ComboBox下拉菜单
        }

        //全局变量,实体类的两个对象
        //创建变量实例
        public Variable_Ads var;

        #region 初始化ComboBox下拉菜单        
        void Frm_NewVar_Mod_Load(object sender, EventArgs e)
        {
            //初始化ComboBox下拉菜单
            this.cmb_DataType.Items.Add("Bool");
            this.cmb_DataType.Items.Add("Signed");
            this.cmb_DataType.Items.Add("Unsigned");
            this.cmb_DataType.Items.Add("Hex");
            this.cmb_DataType.Items.Add("Long");
            this.cmb_DataType.Items.Add("Long Inverse");
            this.cmb_DataType.Items.Add("Float");
            this.cmb_DataType.Items.Add("Float Inverse");
            this.cmb_DataType.Items.Add("Double");
            this.cmb_DataType.Items.Add("Double Inverse");
            this.cmb_DataType.SelectedIndex = 6;
        }
        #endregion

        #region 点击确认按钮,窗体传值到对象
        private void btn_OK_Click(object sender, EventArgs e)
        {
            //实体类Variable_Ads实例化
            var = new Variable_Ads();
            var.VarName = this.txt_VarName.Text.Trim();
            var.DataType = this.cmb_DataType.Text.Trim();
            //CheckBox是否勾选
            var.IsFiling = this.chk_IsFiling.Checked ? "1" : "0";//是否归档
            var.IsAlarm = this.chk_IsAlarm.Checked ? "1" : "0";//是否报警
            var.IsReport = this.chk_IsReport.Checked ? "1" : "0";//是否存入报表
            var.Note = this.txt_Note.Text.Trim();
            
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        #endregion
    }
}
